import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import java.util.List;

import static java.lang.Thread.sleep;

public class Main {
    public static void main(String[] args) throws InterruptedException {
        int flag = 0;
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--remote-allow-origins=*");
        WebDriver webDriver = new ChromeDriver(options);
        webDriver.get("https://www.baidu.com");
        WebElement element = webDriver.findElement(By.cssSelector(".s_ipt"));
        element.sendKeys("软件测试");
        webDriver.findElement(By.cssSelector("#su")).click();
        sleep(3000);
        List<WebElement> elements = webDriver.findElements(By.cssSelector("a em"));
        for (int i = 0; i < elements.size(); i++) {
            if (!elements.get(i).getText().contains("测试")||elements.get(i).getText().contains("软件测试")){
                flag = 1;
                System.out.println(elements.get(i).getText());
                System.out.println("测试通过");
                break;
            }
        }
        if (flag == 0){
            System.out.println("测试不通过");
        }
    }
}